home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
popup
/
popup.frm
< prev
next >
Wrap
Text File
|
1995-02-19
|
11KB
|
430 lines
VERSION 2.00
Begin Form NotePad
BackColor = &H00C0C0C0&
Caption = "Popup Menu Custom Control Demo"
ClientHeight = 5715
ClientLeft = 945
ClientTop = 1605
ClientWidth = 9510
Height = 6405
Left = 885
LinkTopic = "Form1"
ScaleHeight = 5715
ScaleWidth = 9510
Top = 975
Width = 9630
Begin Frame Frame2
BackColor = &H00C0C0C0&
Caption = "Position Popup"
Height = 1815
Left = 7680
TabIndex = 7
Top = 3240
Width = 1695
Begin OptionButton Leftpos
BackColor = &H00C0C0C0&
Caption = "Left"
Height = 255
Left = 120
TabIndex = 10
Top = 1440
Width = 1455
End
Begin OptionButton Centrepos
BackColor = &H00C0C0C0&
Caption = "Centre"
Height = 255
Left = 120
TabIndex = 9
Top = 960
Width = 1455
End
Begin OptionButton Rightpos
BackColor = &H00C0C0C0&
Caption = "Right"
Height = 255
Left = 120
TabIndex = 8
Top = 480
Width = 1455
End
End
Begin Frame Frame1
BackColor = &H00C0C0C0&
Caption = "Use Button"
Height = 1455
Left = 7680
TabIndex = 4
Top = 1680
Width = 1695
Begin OptionButton Either
BackColor = &H00C0C0C0&
Caption = "Either"
Height = 255
Left = 120
TabIndex = 6
Top = 360
Width = 1455
End
Begin OptionButton Left
BackColor = &H00C0C0C0&
Caption = "Left"
Height = 255
Left = 120
TabIndex = 5
Top = 960
Width = 1455
End
End
Begin CommandButton Command3
Caption = "Custom Popup "
Height = 375
Left = 7680
TabIndex = 3
Top = 1080
Width = 1575
End
Begin CommandButton Command2
Caption = "Popup Edit"
Height = 375
Left = 7680
TabIndex = 2
Top = 600
Width = 1575
End
Begin CommonDialog CMDialog1
Left = 7560
Top = 5160
End
Begin CommandButton Command1
Caption = "Popup File"
Height = 375
Left = 7680
TabIndex = 1
Top = 120
Width = 1575
End
Begin Popup Popup1
Enabled = -1 'True
Left = 8280
MenuAlignment = 0 'Right
MenuCaption = ""
Top = 5160
TrackingButton = 0 'Left Button
End
Begin TextBox Document
Height = 5415
HideSelection = 0 'False
Left = 0
MultiLine = -1 'True
ScrollBars = 3 'Both
TabIndex = 0
Top = 0
Width = 7455
End
Begin Menu mnuFile
Caption = "&File"
Begin Menu mnuFNew
Caption = "&New"
End
Begin Menu mnuFOpen
Caption = "&Open..."
End
Begin Menu mnuFSave
Caption = "&Save"
End
Begin Menu mnuFSaveAs
Caption = "Save &As..."
End
Begin Menu mnuFSep
Caption = "-"
End
Begin Menu mnuFExit
Caption = "E&xit"
End
End
Begin Menu mnuEdit
Caption = "&Edit"
Begin Menu mnuECut
Caption = "Cu&t"
Shortcut = ^X
End
Begin Menu mnuECopy
Caption = "&Copy"
Shortcut = ^C
End
Begin Menu mnuEPaste
Caption = "&Paste"
Shortcut = ^V
End
Begin Menu mnuEDelete
Caption = "De&lete"
Shortcut = {DEL}
End
Begin Menu mnuESep1
Caption = "-"
End
Begin Menu mnuESelectAll
Caption = "Select &All"
End
Begin Menu mnuETime
Caption = "Time/&Date"
End
End
End
Sub Centrepos_Click ()
popup1.MenuAlignment = 1
End Sub
Sub Command1_Click ()
popup1.Clear
popup1.MenuCaption = "&File"
End Sub
Sub Command2_Click ()
popup1.Clear
popup1.MenuCaption = "&Edit"
End Sub
Sub Command3_Click ()
popup1.Clear
popup1.AddItem "&File"
popup1.AddItem Chr$(9) & "1" & Chr$(9) & "&New"
popup1.AddItem Chr$(9) & "2" & Chr$(9) & "&Open"
popup1.AddItem Chr$(9) & "3" & Chr$(9) & "&Save"
popup1.AddItem Chr$(9) & "4" & Chr$(9) & "Save &As"
popup1.AddItem Chr$(9) & "-"
popup1.AddItem Chr$(9) & "5" & Chr$(9) & "E&xit"
popup1.AddItem "&Edit"
popup1.AddItem Chr$(9) & "6" & Chr$(9) & "Cu&t"
popup1.AddItem Chr$(9) & "7" & Chr$(9) & "&Copy"
popup1.AddItem Chr$(9) & "8" & Chr$(9) & "&Paste"
popup1.AddItem Chr$(9) & "9" & Chr$(9) & "De&lete"
popup1.AddItem Chr$(9) & "-"
popup1.AddItem Chr$(9) & "10" & Chr$(9) & "Select &All"
popup1.AddItem Chr$(9) & "11" & Chr$(9) & "Time/&Date"
End Sub
Sub Document_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
'
If Button = 2 Then ' activate when user clicks the right mousebutton
popup1.Activate = 1
Select Case popup1.MenuReturnID
Case 1
mnuFNew_Click
Case 2
mnuFOpen_Click
Case 3
mnuFSave_Click
Case 4
mnuFSaveAs_Click
Case 5
mnuFExit_Click
'
Case 6
mnuECut_Click
Case 7
mnuECopy_Click
Case 8
mnuEPaste_Click
Case 9
mnuEDelete_Click
Case 10
mnuESelectAll_Click
Case 11
mnuETime_Click
End Select
End If
'
End Sub
Sub EditCopyProc ()
ClipBoard.SetText Document.SelText
End Sub
Sub EditCutProc ()
ClipBoard.SetText Document.SelText
Document.SelText = ""
End Sub
Sub EditPasteProc ()
Document.SelText = ClipBoard.GetText()
End Sub
Sub Either_Click ()
popup1.TrackingButton = 1
End Sub
Sub FileNew ()
Document.Text = ""
Document.SetFocus
End Sub
Sub FOpenProc ()
Dim RetVal
On Error Resume Next
Dim OpenFileName As String
CMDialog1.Filename = "*.txt"
CMDialog1.Action = 1
If Err <> 32755 Then 'user pressed cancel
OpenFileName = CMDialog1.Filename
OpenFile (OpenFileName)
End If
End Sub
Sub Form_Load ()
Either.Value = True
Rightpos.Value = True
Document.Text = "Click the right mousebutton to see the popup menu"
popup1.MenuCaption = "&File"
End Sub
Sub Form_Resize ()
If windowstate <> 1 And ScaleHeight <> 0 Then
Document.Visible = False
Document.Height = ScaleHeight
Document.Width = ScaleWidth * .8
Command1.Left = Document.Width + 100
Command2.Left = Document.Width + 100
Command3.Left = Document.Width + 100
Frame1.Left = Document.Width + 100
Frame2.Left = Document.Width + 100
Document.Visible = True
End If
End Sub
Function GetFileName ()
On Error Resume Next
CMDialog1.Filename = "File1.Txt"
CMDialog1.Action = 2
If Err <> 32755 Then 'User cancelled dialog
GetFileName = CMDia